# //数据集DataFrame
import pandas as pd
data={"Name":["张三","李四","王五"],"Age":[26,19,20],"Date":["2023-01-01","2023-01-02","2023-01-03"]}
df=pd.DataFrame(data)
print(df)
df["Date"]=pd.to_datetime(df["Date"])
print(df)
# //条件筛选
df_age=df[(df["Age"]>18)&(df["Date"]=="2023-01-02")]
print(df_age)
# //分组聚合
df_group=df.groupby("Age").agg({"Date":"count"})
print(df_group)
# df.to_csv("res1.csv",index=False)
# df.to_excel("res2.xlsx",sheet_name="Sheet1",index=False)
#年龄标准差
df_std=df["Age"].std()
print(df_std)
#保留两位小数
df_std=round(df_std,2)
print(df_std)
#numpy
import numpy as np
# //numpy数组
arr=np.array([1,2,3,4,5])
print(arr)
# //numpy数组运算
arr2=arr*2
print(arr2)
# //numpy数组统计
arr_mean=arr.mean()
print(arr_mean)
# //numpy数组统计
arr_max=arr.max()
print(arr_max)
# //numpy数组统计
arr_min=arr.min()
print(arr_min)
# //numpy数组统计
arr_sum=arr.sum()
print(arr_sum)
# //numpy数组统计
arr_std=arr.std()
print(arr_std)
# //numpy数组统计
arr_var=arr.var()#方差
print(arr_var)
# //numpy数组统计
arr_median=np.median(arr)#中位数
print(arr_median)
# //numpy数组统计
arr_quantile=np.quantile(arr,0.25)#25%分位数
print(arr_quantile)
# //numpy数组统计
arr_quantile=np.quantile(arr,0.75)#75%分位数
print(arr_quantile)
# //numpy数组统计
arr_quantile=np.quantile(arr,0.5)#50%分位数
print(arr_quantile)









